<?php
namespace app\common\model;

class ClueErrorLog extends Base
{
    protected $autoWriteTimestamp = true;

    //自定义日志标题
    protected static $title = '';
    //自定义日志内容
    protected static $content = '';
    //自定义日志内容
    protected static $order_sn = '';

    public static function setTitle($title)
    {
        self::$title = $title;
    }

    public static function setContent($content)
    {
        self::$content = $content;
    }

    public static function setOrderSn($order_sn)
    {
        self::$order_sn = $order_sn;
    }

    public static function record($clue_id='', $title = '', $content='')
    {
        !$clue_id && $clue_id = self::$order_sn;
        !$title && $title = self::$title;
        !$content && $content = self::$content;
        if (!$content){
            $content = request()->param();
        }

        self::create([
            'clue_id'     => $clue_id,
            'title'     => $title,
            'content'   => !is_scalar($content) ? json_encode($content,320) : $content,
            'ip'        => request()->ip()
        ]);

    }
}